package outbound.shipping.dataObjects
{
	import common.utils.DateManager;	
	import mx.collections.ArrayCollection;

	[Bindable]
	public class ShipmentDetailDO
	{
		public var INTERNAL_SHIPMENT_LINE_NUM:Number = 0;
		public var INTERNAL_SHIPMENT_NUM:Number = 0;
		public var WAREHOUSE:String = "";
		public var COMPANY:String = "";
		public var SHIPMENT_ID:String = "";
		public var ERP_ORDER:String = "";
		public var ERP_ORDER_LINE_NUM:Number = 0;
		public var SHIPMENT_TYPE:String = "";
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var REQUESTED_QTY:Number = 0;
		public var TOTAL_QTY:Number = 0;
		public var REQUEST_QTY:Number = 0;
		public var QUANTITY_UM:String = "";
		public var ALLOCATION_RULE:String = "";
		public var PICK_LOC:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var DOCK_LOC:String = "";
		public var INVENTORY_STS:String = "";
		public var PACKING_CLASS:String = "";
		public var ATTRIBUTE_TRACK:String = "N";
		public var STATUS:Number = 100;
		public var INTERNAL_WAVE_NUM:Number = 0;

		public function ShipmentDetailDO()
		{
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}			
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<SHIPMENT_DETAIL>
					<INTERNAL_SHIPMENT_LINE_NUM>{INTERNAL_SHIPMENT_LINE_NUM}</INTERNAL_SHIPMENT_LINE_NUM>
					<INTERNAL_SHIPMENT_NUM>{INTERNAL_SHIPMENT_NUM}</INTERNAL_SHIPMENT_NUM>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<COMPANY>{COMPANY}</COMPANY>
					<SHIPMENT_ID>{SHIPMENT_ID}</SHIPMENT_ID>
					<ERP_ORDER>{ERP_ORDER}</ERP_ORDER>
					<ERP_ORDER_LINE_NUM>{ERP_ORDER_LINE_NUM}</ERP_ORDER_LINE_NUM>
					<SHIPMENT_TYPE>{SHIPMENT_TYPE}</SHIPMENT_TYPE>
					<ITEM>{ITEM}</ITEM>
					<ITEM_DESC>{ITEM_DESC}</ITEM_DESC>
					<REQUESTED_QTY>{REQUESTED_QTY}</REQUESTED_QTY>
					<TOTAL_QTY>{TOTAL_QTY}</TOTAL_QTY>
					<REQUEST_QTY>{REQUEST_QTY}</REQUEST_QTY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<ALLOCATION_RULE>{ALLOCATION_RULE}</ALLOCATION_RULE>
					<PICK_LOC>{PICK_LOC}</PICK_LOC>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
					<DOCK_LOC>{DOCK_LOC}</DOCK_LOC>
					<INVENTORY_STS>{INVENTORY_STS}</INVENTORY_STS>
					<ATTRIBUTE_TRACK>{ATTRIBUTE_TRACK}</ATTRIBUTE_TRACK>
					<STATUS>{STATUS}</STATUS>
				</SHIPMENT_DETAIL>;			
			
			return xmlObj;
		}

		public static function getShipmentDetails(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var shpDtl:ShipmentDetailDO = new ShipmentDetailDO();
				shpDtl.Init(xml);
				ac.addItem(shpDtl);
			}
			return ac;
		}		

	}
}